import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn } from 'typeorm';
import { EnterpriseEntity } from '../../enterprise/entities/enterprise.entity';
import { BaseEntity } from 'src/common/entitys/base';

@Entity('sys_waybill', { comment: '货运单' })
export class WaybillEntity extends BaseEntity {
  @PrimaryGeneratedColumn({ name: 'waybill_id', type: 'int', comment: '货运单id' })
  waybillId: number;

  @Column({ name: 'enterprise_id', type: 'char', length: 36, nullable: true, comment: '与企业表关联' })
  enterpriseId: string | null;

  @Column({ name: 'waybill_status', type: 'varchar', length: 255, default: 'received', comment: '货运状态枚举: received-已揽件, instore-已入库, incar-已装车, outcar-已卸货, outstore-已出库' })
  waybillStatus: string;

  @Column({ name: 'send_name', type: 'varchar', length: 255, comment: '发货人' })
  sendName: string;

  @Column({ name: 'send_phone', type: 'varchar', length: 255, comment: '发货人电话' })
  sendPhone: string;

  @Column({ name: 'send_date', type: 'datetime', nullable: true, comment: '发货时间' })
  sendDate: Date | null;

  @Column({ name: 'send_address', type: 'varchar', length: 255, comment: '发货地址 省/市/区/详细地址' })
  sendAddress: string;

  @Column({ name: 'send_lon', type: 'varchar', length: 255, comment: '地图选点 经度' })
  sendLon: string;

  @Column({ name: 'send_lat', type: 'varchar', length: 255, comment: '地图选点 纬度' })
  sendLat: string;

  @Column({ name: 'receive_name', type: 'varchar', length: 255, comment: '收货人' })
  receiveName: string;

  @Column({ name: 'receive_phone', type: 'varchar', length: 255, comment: '收货人电话' })
  receivePhone: string;

  @Column({ name: 'receive_date', type: 'datetime', nullable: true, comment: '收货时间' })
  receiveDate: Date | null;

  @Column({ name: 'receive_address', type: 'varchar', length: 255, nullable: true, comment: '收货地址 省/市/区/详细地址' })
  receiveAddress: string | null;

  @Column({ name: 'receive_lon', type: 'varchar', length: 255, nullable: true })
  receiveLon: string | null;

  @Column({ name: 'receive_lat', type: 'varchar', length: 255, nullable: true })
  receiveLat: string | null;

  @ManyToOne(() => EnterpriseEntity)
  @JoinColumn({ name: 'enterprise_id' })
  enterprise: EnterpriseEntity;
}
